import shutil, os, sys
from pathlib import Path
import datetime
import updateModelParamsUtils, MyUtils

#正明
def demo(rootPath,local,srcProductPath="product1/model", dstModelPathList=['product1/model', 'product2/model'],commitInfo="xxx"):
    #rootPath = 'E:/workspace/0_model/0_shenzhenHuaxing_piantie-new/'
     modelName = srcProductPath.split('/')[-1]
     srcModelPath = srcProductPath+"/"
     if( not os.path.exists(srcModelPath)):
            print("srcModelPath path not exist: ", srcModelPath)
            exit(0)
     else:
         print(">>> src model: ", srcModelPath)
         print(">>>")

     dstModelPathList = dstModelPathList
    
    #["正明非超", "正明超贴", "正暗","背明", "透射"]

    #step参数不更新列表,正明
     if local == "正明非超":
        stepIdxListNot = [
            0,
            319  #AA区
            ,333  #油墨水平
            ,335  #油墨垂直
        ]
     elif local == "正暗":
        stepIdxListNot = [
            0,
            315  #AA区
            ,313  #油墨外围
            ,329  #油墨与AA边界
        ]
     elif local == "背明":
        stepIdxListNot = [
            0,
            310  #AA区
            ,367  #油墨水平
            ,351  #油墨垂直
        ]
     elif local == "透射":
        stepIdxListNot = [
            0,
        ]
     elif local == "巡边":
        stepIdxListNot = [
            0,
        ]
     else:
         print("工位错误："+local)
         exit(0)
     publish = rootPath
     updateModelParamsUtils.modelUpdateDemo(commitInfo, srcModelPath,dstModelPathList,stepIdxListNot,publish)

if __name__ == "__main__":  
    currentTime = datetime.datetime.now().strftime('%Y-%m-%d  %H:%M:%S')
    currentDate = datetime.datetime.now().strftime('%Y-%m-%d')

    rootPath = 'E:/workspace/0_model/0_shenzhenHuaxing_piantie-new/'

    positions_total = ["正明非超", "正暗","背明", "透射", "巡边"]  #"正明超贴"
    dstProductsList=["65inch_6450JAHAO", "65inch_64533ABA06",
                    "65inch_64556060004","65inch_6459T050004",
                     "75inch_74696050001"
                     ]
    #dstProductsList = ["65inch_6459T050004"]   #测试用

    #编辑参数####################################################
    srcProduct="65inch_64556060004"
    positions = ["正明非超", "正暗","背明","透射", "巡边"]
    
    commitInfo = "修复变换矩阵方向问题"
    #编辑参数####################################################


    print("commitInfo: ", commitInfo)
    inputStr = input("当前源model："+srcProduct+"\n是否确认更新(y/n): ")
    print(inputStr)
    if inputStr != 'y':
        print("指令错误: " + inputStr)
        exit(0)

    commitInfo = commitInfo+", 同步model-"+srcProduct
    for position in positions:
        dstModelPathList = []
        for dstProducts in dstProductsList:
            dstModelPathList.append(rootPath+dstProducts+"/"+position+"/model_"+position+"_"+dstProducts+"/")
        

        srcProductPath=rootPath+srcProduct+"/"+position+"/model_"+position+"_"+srcProduct
        demo(rootPath=rootPath,local=position, srcProductPath=srcProductPath, 
            dstModelPathList=dstModelPathList,commitInfo=commitInfo)


    exit(0)


    
